import request from '../../utils/request';

// 机构管理相关 API

// 推荐机构
export const recommendOrg = (orgId: string, data: any) => {
    return request({
        url: `/system/api/org/${orgId}/recommend`,
        method: 'post',
        data
    });
};

// 获取机构权限
export const getOrgPermissions = (orgId: string) => {
    return request({
        url: `/system/api/org/${orgId}/permissions`,
        method: 'get'
    });
};

// 更新机构审批状态
export const updateOrgApprovalStatus = (orgId: string, data: any) => {
    return request({
        url: `/system/api/org/${orgId}/approval-status`,
        method: 'put',
        data
    });
};

// 更新机构状态
export const updateOrgStatus = (id: string, status: number) => {
    return request({
        url: `/system/api/org/${id}/status`,
        method: 'put',
        params: { status }
    });
};

// 更新机构
export const updateOrg = (data: any) => {
    return request({
        url: '/system/api/org/update',
        method: 'put',
        data
    });
};

// 提交机构审批
export const submitOrgApproval = (orgId: string, data: any) => {
    return request({
        url: `/system/api/org/${orgId}/submit-approval`,
        method: 'post',
        data
    });
};

// 拒绝机构审批
export const rejectOrgApproval = (orgId: string, data: any) => {
    return request({
        url: `/system/api/org/${orgId}/reject`,
        method: 'post',
        data
    });
};

// 通过机构审批
export const approveOrg = (orgId: string, data: any) => {
    return request({
        url: `/system/api/org/${orgId}/approve`,
        method: 'post',
        data
    });
};

// 获取机构列表
export const getOrgList = () => {
    return request({
        url: '/system/api/org/list',
        method: 'get'
    });
};

// 创建机构
export const createOrg = (data: any) => {
    return request({
        url: '/system/api/org/create',
        method: 'post',
        data
    });
};

// 检查机构权限
export const checkOrgPermissions = (orgId: string, data: any) => {
    return request({
        url: `/system/api/org/${orgId}/permissions/check`,
        method: 'post',
        data
    });
};

// 获取机构附件
export const getOrgAttachments = (orgId: string) => {
    return request({
        url: `/system/api/org/${orgId}/attachments`,
        method: 'get'
    });
};

// 获取机构所有附件
export const getAllOrgAttachments = (orgId: string) => {
    return request({
        url: `/system/api/org/${orgId}/attachments/all`,
        method: 'get'
    });
};

// 根据ID获取机构
export const getOrgById = (id: string) => {
    return request({
        url: `/system/api/org/${id}`,
        method: 'get'
    });
};

// 获取推荐机构
export const getRecommendedOrgs = () => {
    return request({
        url: '/system/api/org/recommended',
        method: 'get'
    });
};

// 删除机构
export const deleteOrg = (id: string) => {
    return request({
        url: `/system/api/org/${id}`,
        method: 'delete'
    });
};
